package com.example.experiment05.mapper;

import com.example.experiment05.dto.UserAddress02;
import com.example.experiment05.entity.User;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @description:
 * @author: YancyZhang
 * @time: 2022/6/20 15:56
 */
public class UserAddress02RowMapper implements RowMapper<UserAddress02> {
    @Override
    public UserAddress02 mapRow(ResultSet rs, int rowNum) throws SQLException {
//        DateTimeFormatter formatter = DateTimeFormatterUtils.getFormatter();
        User user = User.builder()
                .id(rs.getLong("user_id"))
                .name(rs.getString("name"))
                .createTime(rs.getDate("a.create_time"))
                .build();
        return UserAddress02.builder()
                .user(user)
                .id(rs.getLong("a.id"))
                .detail(rs.getString("a.detail"))
                .createTime(rs.getDate("a.create_time"))
                .build();
    }
}